#include "weapon.h"
#include "../core/actor.h"
#include "../world/spell.h"
#include "stats.h"
void weapon::update(float dt)
{
    node::update(dt);
    cool_down_timer_ += dt;

}

void weapon::attack(glm::vec2 position, spell *spell)
{    
    if(spell){
        parent_->getStats()->useMana(mana_cost_);
        cool_down_timer_ = 0;
        spell->setWorldPosition(position);
        game_.getCurrentScene()->safeAddChild(spell); 
    }
}

bool weapon::canAttack()
{
    if (cool_down_timer_ < cool_down_)return false;
    if(!parent_->getStats()->isCanUseMana(mana_cost_))return false;
    return true;
}
